<template>
    <el-card>
        <el-table :data="tableData" border style="width: 100%" size="small">
            <el-table-column type="index" label="#" width="50"></el-table-column>
            <el-table-column label="申请时间" prop="createTime"></el-table-column>
            <el-table-column label="标题" prop="title"></el-table-column>
            <el-table-column label="发布" prop="type">
                <template slot-scope="{row}">
                    <span v-if="row.type===0">发布</span>
                </template>
            </el-table-column>
            <el-table-column label="申请人" prop="createBy"></el-table-column>
            <el-table-column label="审核状态" prop="status">
                <template slot-scope="{row}">
                    <span v-if="row.status===0">待审核</span>
                </template>
            </el-table-column>
            <el-table-column label="操作" width="120" align="center">
                <template slot-scope="scope">
                    <el-button size="small" type="text" @click="handleView(scope.row)">查看</el-button>
                    <el-button size="small" type="text" @click="handleAudit(scope.row)">审核</el-button>
                </template>
            </el-table-column>
        </el-table>
         <el-pagination
                v-show="total>0"
                @size-change="handleSizeChange"
                @current-change="handleCurrentChange"
                background
                :current-page="1"
                :page-sizes="[10, 20, 30, 40,50,100]"
                :page-size="10"
                layout="total, sizes, prev, pager, next, jumper"
                class="pagination-container"
                :total="total">
        </el-pagination>
        <el-dialog :title="`【${title}】-审核`" width="25%" :visible.sync="auditVisible">
            <el-form :model="auditForm" label-width="100px">
              <el-form-item label="审核结果" required prop="approvalResult">
                    <el-radio-group v-model="auditForm.approvalResult">
                        <el-radio :label="2">通过</el-radio>
                        <el-radio :label="1">不通过</el-radio>
                    </el-radio-group>
              </el-form-item>
              <el-form-item label="审核备注" prop="approvalRemark">
                  <el-input v-model="auditForm.approvalRemark" placeholder="审核备注(选填)" size="small" :rows="3"></el-input>
              </el-form-item>
            </el-form>
             <span slot="footer" class="dialog-footer">
                <el-button @click="auditVisible = false" size="mini">取 消</el-button>
                <el-button type="primary" @click="handleSave('auditForm')" size="mini">确 定</el-button>
            </span>
        </el-dialog>
   </el-card>
</template>

<script>
import { getAuditList } from '@/api/aggregate/audit.api'
    export default {
        data() {
          return {
            queryParams: {
                current: 1,
                size: 10,
                status: 0
            },
            tableData: [],
            statusArr: [
                {label: '待审核',value: 0},
                {label: '审核不通过',value: 1},
                {label: '审核通过',value: 2},
                {label: '撤回',value: 3},
            ],
            total: 0,
            FrontendList: [],
            title: '',
            auditVisible: false,
            auditForm: {}
          }
        },
        mounted() {
            this.getList();
        },
        filters: {
            statusFilter(value) {
                if(value===1) {
                    return '未发布';
                }
            }
        },
        methods: {
            handleAudit(row) {
                this.title = row.title
                this.auditVisible = true;
            },
            async getList() {
                const result = await getAuditList(this.queryParams);
                if(result.code === 200) {
                    this.tableData = result.data.records;
                    this.total = result.data.total
                }
            },
            handleSizeChange(val) {
                this.queryParams.size = val;
                this.getList();
            },
            handleCurrentChange(val) {
                this.queryParams.current = val;
                this.getList();
            },
        }
    }
</script>
<style lang="scss" scoped>
.pagination-container {
    padding: 10px;
    text-align: right;
}
</style>